package org.example.phoenix5;

import org.apache.phoenix.queryserver.client.ThinClientUtil;

import java.sql.*;

public class PhoenixTest {
    public static void main(String[] args) throws SQLException {
        String conUrl = ThinClientUtil.getConnectionUrl("hadoop1", 8765);
        Connection connection = DriverManager.getConnection(conUrl);
        PreparedStatement preparedStatement = connection.prepareStatement("select id,name,addr from test");
        ResultSet resultSet = preparedStatement.executeQuery();
        while (resultSet.next()) {
            System.out.println("ID:" + resultSet.getString(1) +
                    ",name:" + resultSet.getString(2) +
                    ",addr:" + resultSet.getString(3));
        }
        resultSet.close();
        preparedStatement.close();
        connection.close();
    }
}
